import { Notification, Message } from 'element-ui';

export function notify(msg, options) {
  let defaultOptions = {
    showClose: false,
    type: 'success',
    duration: 3 * 1000,
    position: 'top-right',
  };
  defaultOptions = Object.assign(defaultOptions, options);
  let defaultMsg = '操作成功!';
  if (defaultOptions.type === 'error') {
    defaultMsg = '操作失败!';
  }
  Notification({
    title: '提示',
    message: msg || defaultMsg,
    ...defaultOptions,
  });
}

export function message(msg, options) {
  let defaultOptions = {
    showClose: false,
    type: 'error',
    duration: 3 * 1000,
  };
  defaultOptions = Object.assign(defaultOptions, options);
  Message({
    message: msg,
    ...defaultOptions,
  });
}
